1. Function to return characters to the LEFT of a specified character within a string


			
  '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  'Name:  de_ChLeft
  '
  'Comments:
  '  This function returns the characters to the left of a specified occurance
  '  of a specified identifier in a string of characters
  '
  'In:
  '  WhatChar  --> The identifier marking the point at which to stop
  '                reading the source string
  '  WhatOcc   --> The occurance of the identifier to look for
  '  srcString --> The source string to read in
  '
  'Out:  String of characters
  '
  'Examples of Usage:
  '  1. To return the string of characters to the left of the FIRST SPACE
  '
  '     de_ChLeft(" ", 1, "String To Search") returns the word "String"
  '
  '  2. To return the string of characters to the left of the THIRD #
  '
  '     de_ChLeft("#", 3, "#01#02#03#04") returns the string #01#02
  '
  'Created: 06/28/98 by William Schmidt and Stephen Negus
  '
  'Modifications:
  'Date       Author              Description
  '08/28/99   Stephen Negus       Added header section and error handling
  '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  Function de_ChLeft(WhatChar As String, WhatOcc As Integer, srcString _
            As String) As String
    On Error GoTo de_ChLeft_Err
  			
    Dim i As Integer, j As Integer, k As Integer
  			
    k = 0
    j = 0
  			    
    For i = 1 To WhatOcc
      j = InStr(k + 1, srcString, WhatChar)
      k = j
    Next i
  			
    de_ChLeft = Left(srcString, k - 1)
  			
  de_ChLeft_Exit:
    Exit Function
  			    
  de_ChLeft_Err:
    Dim strMsg As String
    strMsg = "Error " & Err.Number & " has occurred."
    strMsg = strMsg & " The Description is: " & Err.Description
    MsgBox strMsg
    Resume de_ChLeft_Exit
  			    
  End Function
			

Copyright © 1999-2000, Doulos Enterprises
All Rights Reserved
Terms of Use